/**
 * Program  : TestActivity.java
 * Author   : qianj
 * Create   : 2012-5-25 上午09:46:45
 *
 * Copyright 2012 by newyulong Technologies Ltd.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information
 * of newyulong Technologies Ltd.("Confidential Information").  
 * You shall not disclose such Confidential Information and shall 
 * use it only in accordance with the terms of the license agreement 
 * you entered into with newyulong Technologies Ltd.
 *
 */

package cn.learn.base;

import java.util.HashMap;
import java.util.Map;

import android.content.Intent;
import android.os.Bundle;
import android.widget.RadioGroup;
import cn.learn.base.activity.FifthActivity;
import cn.learn.base.activity.FourthActivity;
import cn.learn.base.activity.SecondActivity;
import cn.learn.base.activity.ThirdActivity;
import cn.learn.base.activity.ViewPagerActivity;

/**
 * 带有标题和tabbar
 * @author qianj
 * @version 1.0.0
 * @2012-5-25 上午09:46:45
 */
public class TestActivity extends BaseFrameActivity {

	public static final String TAB_ITEM_1 = "tabItem1";
	public static final String TAB_ITEM_2 = "tabItem2";
	public static final String TAB_ITEM_3 = "tabItem3";
	public static final String TAB_ITEM_4 = "tabItem4";
	public static final String TAB_ITEM_5 = "tabItem5";
	private int index = -1;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);

		// 初如化tabbar如何跳转
		Map<String, Intent> tabHostMap = new HashMap<String, Intent>();
		tabHostMap.put(TAB_ITEM_1, new Intent(this, ViewPagerActivity.class));
		tabHostMap.put(TAB_ITEM_2, new Intent(this, SecondActivity.class));
		tabHostMap.put(TAB_ITEM_3, new Intent(this, ThirdActivity.class));
		tabHostMap.put(TAB_ITEM_4, new Intent(this, FourthActivity.class));
		tabHostMap.put(TAB_ITEM_5, new Intent(this, FifthActivity.class));

		setTabHost(tabHostMap);

	}

	@Override
	protected void handleTitleBarEvent(int buttonId) {
		if (buttonId == 0) {
			finish();
		}

		if (buttonId == 1) {

			Intent i = new Intent(TestActivity.this, IndexActivity.class);
			startActivity(i);
			
			//这儿是为了区分是在哪个界面时点击了title里面右边的图标
			switch (index) {
			case 1:
				break;
			case 2:
				break;
			case 3:
				break;
			case 4:
				break;
			case 5:
				break;
			default:
			}
		}
	}

	@Override
	public void onCheckedChanged(RadioGroup group, int checkedId) {
		switch (checkedId) {
		case R.id.radio_button1:
			setCurrentTab(TAB_ITEM_1);
			SetTitle("11111");
			setTitleBar(R.drawable.title_back, "", R.drawable.title_home, "");
			index = 1;
			break;
		case R.id.radio_button2:
			setCurrentTab(TAB_ITEM_2);
			SetTitle("22222");
			setTitleBar(R.drawable.title_back, "", R.drawable.title_home, "");
			index = 2;
			break;
		case R.id.radio_button3:
			SetTitle("33333");
			setTitleBar(R.drawable.title_back, "", R.drawable.title_home, "");
			setCurrentTab(TAB_ITEM_3);
			index = 3;
			break;
		case R.id.radio_button4:
			setCurrentTab(TAB_ITEM_4);
			SetTitle("44444");
			setTitleBar(R.drawable.title_back, "", R.drawable.title_home, "");
			index = 4;
			break;
		case R.id.radio_button5:
			setCurrentTab(TAB_ITEM_5);
			setTitleBar(R.drawable.title_back, "", R.drawable.title_home, "");
			SetTitle("55555");
			index = 5;
			break;
		default:
			break;
		}

	}

}
